/*
 * 作者: junmu
 * 时间: 2025-07-22
 */
package com.hzbc.faceattendance.repository;

import com.hzbc.faceattendance.model.PushMessage;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;
import java.util.Optional;

@Repository
public interface PushMessageRepository extends JpaRepository<PushMessage, Long> {
    Page<PushMessage> findByCreateTimeBetween(Date startDate, Date endDate, Pageable pageable);
    Page<PushMessage> findByTypeAndCreateTimeBetween(Integer type, Date startDate, Date endDate,Pageable pageable);
    Page<PushMessage> findByPushStatusAndCreateTimeBetween(Integer pushStatus, Date startDate, Date endDate, Pageable pageable);
    List<PushMessage> findByPushStatusAndCreateTimeBetween(Integer pushStatus, Date startDate, Date endDate);

    Page<PushMessage> findByTypeAndPushStatusAndCreateTimeBetween(Integer type, Integer pushStatus, Date startDate, Date endDate, Pageable pageable);

    @Query("SELECT p FROM PushMessage p WHERE p.id = :aLong and p.pushStatus = :status")
    PushMessage findByIdandstatus(Long aLong,Integer status);

    @Query("SELECT p FROM PushMessage p WHERE p.id = :aLong")
    PushMessage findByIduseSql(Long aLong);

    Page<PushMessage> findByWhiteListIsNotNullAndCreateTimeBetween(Date date, Date date1, Pageable pageable);
}